package xyz.gzdxc.common.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.gzdxc.common.constant.ResultCode;
import xyz.gzdxc.common.service.MenuService;
import xyz.gzdxc.common.util.ResultBuilder;
import xyz.gzdxc.common.vo.response.MenuTreeVo;
import xyz.gzdxc.common.vo.response.ResultVo;

import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController {
    private static final Logger LOG = LoggerFactory.getLogger(MenuController.class);

    @Autowired
    MenuService menuService;

    @GetMapping("/getMenuList/{userId}")
    ResultVo getMenuList(@PathVariable Long userId){
        LOG.info("userId => {}", userId);
        List<MenuTreeVo> menuTreeVoList = menuService.getMenuTreeByUserId(userId);
        LOG.info("menuTreeVoList => {}", menuTreeVoList);
        return ResultBuilder.build(ResultCode.SUCCESS, menuTreeVoList);
    }
}
